<?php
/**
 * Skyline :: Patterns & component framework
 * Copyright 2010-2011 Ian Unruh (Xerof3ar)
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
namespace Skyline\Structure\Multiset;

use Skyline\Comparator\ComparatorInterface;
use Skyline\Structure\CollectionInterface;

/**
 * A multiset (or bag) is a set that counts the number of times an element 
 * exists in a collection
 * 
 * @author Ian Unruh (Xerof3ar) <ianunruh@gmail.com>
 * @since Class avaliable since release 1.0
 */
interface MultisetInterface extends CollectionInterface
{
	/**
	 * Adds an element <i>n</i> number of times
	 * 
	 * @param mixed $element
	 * @param int $count
	 * @return void
	 */
	public function addCount($element, $count);
	
	/**
	 * Returns the count of a given element
	 * 
	 * @param mixed $element
	 * @return int
	 */
	public function getCount($element);
	
	/**
	 * Returns a unique set of the elements in this multiset
	 * @return SetInterface
	 */
	public function getSet();
	
	/**
	 * Removes an element <i>n</i> number of times
	 * 
	 * @param mixed $element
	 * @param int $count
	 * @return void
	 */
	public function removeCount($element, $count);
	
	/**
	 * Sets the count of the element to <i>n</i>
	 * 
	 * @param mixed $element
	 * @param int $count
	 * @return void
	 */
	public function setCount($element, $count);
	
	/**
	 * Sets the count of the element to <i>newCount</i> <b>if</b> its previous
	 * count is equal to <i>oldCount</i>
	 * 
	 * @param mixed $element
	 * @param int $oldCount
	 * @param int $newCount
	 * @return bool Returns true if operation was successful
	 */
	public function setCountIf($element, $oldCount, $newCount);
	
	/**
	 * Sets the comparator used to sort this multiset
	 * 
	 * @param ComparatorInterface $comparator
	 * @return void
	 */
	public function setComparator(ComparatorInterface $comparator);
}